#ifndef LENSTRAYMODULECONFIG_H
#define LENSTRAYMODULECONFIG_H

#include "BasicElement/scaxis.h"
#include "configManager/configobject.h"

class LensTrayModuleConfig : public ConfigObject
{
    Q_OBJECT

    Q_PROPERTY(int ltMagTrayCount READ ltMagTrayCount WRITE setLtMagTrayCount NOTIFY ltMagTrayCountChanged)
    Q_PROPERTY(
        QString ltBufferBeltRunDir READ ltBufferBeltRunDir WRITE setLtBufferBeltRunDir NOTIFY ltBufferBeltRunDirChanged)
    Q_PROPERTY(int detectHasTrayMaxTime READ detectHasTrayMaxTime WRITE setDetectHasTrayMaxTime NOTIFY
                   detectHasTrayMaxTimeChanged)
    Q_PROPERTY(int ltBufferGetTrayTimeout READ ltBufferGetTrayTimeout WRITE setLtBufferGetTrayTimeout NOTIFY
                   ltBufferGetTrayTimeoutChanged)
    Q_PROPERTY(
        QString ltLoaderBeltRunDir READ ltLoaderBeltRunDir WRITE setLtLoaderBeltRunDir NOTIFY ltLoaderBeltRunDirChanged)
    Q_PROPERTY(int ltLoaderPushOutTrayTimeout READ ltLoaderPushOutTrayTimeout WRITE setLtLoaderPushOutTrayTimeout NOTIFY
                   ltLoaderPushOutTrayTimeoutChanged)

public:
    LensTrayModuleConfig(QObject *parent = nullptr) : ConfigObject(parent)
    {
        setOptionalProperty("ltBufferBeltRunDir", toVariantList(SCAxis::DirEnumInfo().names()));
        setOptionalProperty("ltLoaderBeltRunDir", toVariantList(SCAxis::DirEnumInfo().names()));
        init();
    }

    int ltMagTrayCount() const
    {
        return m_ltMagTrayCount;
    }

    QString ltBufferBeltRunDir() const
    {
        return m_ltBufferBeltRunDir;
    }

    int detectHasTrayMaxTime() const
    {
        return m_detectHasTrayMaxTime;
    }

    int ltBufferGetTrayTimeout() const
    {
        return m_ltBufferGetTrayTimeout;
    }

    QString ltLoaderBeltRunDir() const
    {
        return m_ltLoaderBeltRunDir;
    }

    int ltLoaderPushOutTrayTimeout() const
    {
        return m_ltLoaderPushOutTrayTimeout;
    }

public slots:
    void setLtMagTrayCount(int ltMagTrayCount)
    {
        if (m_ltMagTrayCount == ltMagTrayCount)
            return;

        m_ltMagTrayCount = ltMagTrayCount;
        emit ltMagTrayCountChanged(m_ltMagTrayCount);
    }

    void setLtBufferBeltRunDir(QString ltBufferBeltRunDir)
    {
        if (m_ltBufferBeltRunDir == ltBufferBeltRunDir)
            return;

        m_ltBufferBeltRunDir = ltBufferBeltRunDir;
        emit ltBufferBeltRunDirChanged(m_ltBufferBeltRunDir);
    }

    void setDetectHasTrayMaxTime(int detectHasTrayMaxTime)
    {
        if (m_detectHasTrayMaxTime == detectHasTrayMaxTime)
            return;

        m_detectHasTrayMaxTime = detectHasTrayMaxTime;
        emit detectHasTrayMaxTimeChanged(m_detectHasTrayMaxTime);
    }

    void setLtBufferGetTrayTimeout(int ltBufferGetTrayTimeout)
    {
        if (m_ltBufferGetTrayTimeout == ltBufferGetTrayTimeout)
            return;

        m_ltBufferGetTrayTimeout = ltBufferGetTrayTimeout;
        emit ltBufferGetTrayTimeoutChanged(m_ltBufferGetTrayTimeout);
    }

    void setLtLoaderBeltRunDir(QString ltLoaderBeltRunDir)
    {
        if (m_ltLoaderBeltRunDir == ltLoaderBeltRunDir)
            return;

        m_ltLoaderBeltRunDir = ltLoaderBeltRunDir;
        emit ltLoaderBeltRunDirChanged(m_ltLoaderBeltRunDir);
    }

    void setLtLoaderPushOutTrayTimeout(int ltLoaderPushOutTrayTimeout)
    {
        if (m_ltLoaderPushOutTrayTimeout == ltLoaderPushOutTrayTimeout)
            return;

        m_ltLoaderPushOutTrayTimeout = ltLoaderPushOutTrayTimeout;
        emit ltLoaderPushOutTrayTimeoutChanged(m_ltLoaderPushOutTrayTimeout);
    }

signals:
    void ltMagTrayCountChanged(int ltMagTrayCount);

    void ltBufferBeltRunDirChanged(QString ltBufferBeltRunDir);

    void detectHasTrayMaxTimeChanged(int detectHasTrayMaxTime);

    void ltBufferGetTrayTimeoutChanged(int ltBufferGetTrayTimeout);

    void ltLoaderBeltRunDirChanged(QString ltLoaderBeltRunDir);

    void ltLoaderPushOutTrayTimeoutChanged(int ltLoaderPushOutTrayTimeout);

private:
    int m_ltMagTrayCount = 0;
    QString m_ltBufferBeltRunDir;
    int m_detectHasTrayMaxTime = 500;
    int m_ltBufferGetTrayTimeout = 20000;
    QString m_ltLoaderBeltRunDir;
    int m_ltLoaderPushOutTrayTimeout = 30000;
};

#endif    // LENSTRAYMODULECONFIG_H
